import 'package:flutter/material.dart';
import 'package:x3_base_package/x3_base_package.dart';
import 'package:x3_business_core/business_common_template/enum/business_task_state_enum.dart';

/// author：william on 2021/3/16 14:36
/// email：362661044@qq.com
/// taskState 任务状态 -1 草稿，0执行中 1已关闭 2已完成 3已结束

class BusinessTaskState extends StatelessWidget {
  final int state;

  const BusinessTaskState({Key key, @required this.state}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    if (state is int) return _buildState();
    return SizedBox();
  }

  Widget _buildState() {
    String text = '';
    Color color = BaseBodyTheme.textColor;
    switch (state) {
      case BusinessTaskStateEnum.draft:
        color = BaseBodyTheme.subTextColor;
        text = BusinessTaskStateEnum.draftName;
        break;
      case BusinessTaskStateEnum.executing:
        color = BaseBodyTheme.warning;
        text = BusinessTaskStateEnum.executingName;
        break;
      case BusinessTaskStateEnum.closed:
        color = BaseBodyTheme.subTextColor;
        text = BusinessTaskStateEnum.closedName;
        break;
      case BusinessTaskStateEnum.completed:
        color = BaseBodyTheme.success;
        text = BusinessTaskStateEnum.completedName;
        break;
      case BusinessTaskStateEnum.ended:
        color = BaseBodyTheme.subTextColor;
        text = BusinessTaskStateEnum.endedName;
        break;
    }
    return Text(text, style: TextStyle(color: color, fontSize: 12));
  }
}
